
import 'package:flutter_trip/models/home_model.dart';
import 'package:flutter_trip/models/search_model.dart';
import 'dart:async';
import 'dart:convert';
import 'package:http/http.dart' as http;

const String homeUrl ='http://www.devio.org/io/flutter_app/json/home_page.json';

class SearchDao{
  static Future<SearchModel> fetch(String url,String text)async{
    var url1 = Uri.parse(url);
    final response = await http.get(url1);
    if(response.statusCode==200){
      //中文乱码的问题
      Utf8Decoder utf8decoder = Utf8Decoder();
      var result = json.decode(utf8decoder.convert(response.bodyBytes));
      SearchModel model = SearchModel.fromJson(result);
      model.keyword=text;

      return model;

    }else{
      throw Exception('搜索加载首页信息失败');
    }


  }
}